import os
from ulits import fstool
import time
from login import user
from shopping_car import shopp
from goods import store
from order import pay
from order import gener
from order import buyer_ord
from order import seller_ord



print('欢迎进入联盟订单系统')
while True:
    A = ['买家','卖家','退出']
    s1 = fstool.show(A)
    if s1 == '1':
        buyer_id = user.user_login('buyer.xls','buyer')
        if buyer_id == True:
            continue
        while True:
            A = ['购物','订单管理','修改信息','返回','退出']
            s2 = fstool.show(A)
            if s2 == '1':
                while True:
                    goods_car = shopp.Goods_car(buyer_id)
                    A = ['查询商品','修改商品数量','移除商品','添加商品','支付','返回','退出']
                    s5 = fstool.show(A)
                    if s5 == '1':
                        goods_car.query_goods()
                    elif s5 == '2':
                        goods_car.amend_goods()
                    elif s5 == '3':
                        goods_car.remove_goods()
                    elif s5 == '4':
                        goods_car.add_goods()
                    elif s5 == '5':
                        ww = pay.buyer_pay(buyer_id)#支付成功
                        if ww == True:
                            continue
                    elif s5 == '6':
                        break
                    elif s5 == '7':
                        exit('退出')
                    else:
                        print('输入错误！') 
            elif s2 == '2':#买家订单管理
                buyer_ord.ord_func(buyer_id)

            elif s2 == '3':
                user.amend_user(buyer_id ,'buyer.xls' ,'buyer')
            elif s2 == '4':
                break
            elif s2 == '5':
                exit('退出')
            else:
                print('输入错误！')
    elif s1 == '2':
        seller_id = user.user_login('seller.xls','seller')
        if seller_id == True:
            continue
        while True:
            A = ['库存管理','订单管理','修改信息','返回','退出']
            s3 = fstool.show(A)
            if s3 == '1':
                while True:
                    A = ['查询商品','修改商品','移除商品','添加商品','返回','退出']
                    store_se = store.Store_se(seller_id)
                    s4 = fstool.show(A)
                    if s4 == '1':
                        store_se.seek_carge()
                    elif s4 == '2':
                        store_se.amend_carge()
                    elif s4 == '3':
                        store_se.remove_carge()
                    elif s4 == '4':
                        store_se.add_carge()
                    elif s4 == '5':
                        break
                    elif s4 == '6':
                        exit('退出')
                    else:
                        print('输入错误！')
            elif s3 == '2':#卖家订单管理
                seller_ord.ord_sell(seller_id)

            elif s3 == '3':
                user.amend_user(buyer_id ,'buyer.xls' ,'buyer')
            elif s3 == '4':
                break
            elif s3 == '5':
                exit('退出')
            else:
                print('输入错误！')

    elif s1 == '3':
        exit('退出')
    else:
        print('输入错误！')

